package hips.gui.parameters;

import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

public class ParameterPanel extends javax.swing.JPanel {

    public ParameterPanel(Number defaultAlpha, Number defaultOmega, Comparable maxAlpha, Comparable maxOmega) {
        initComponents();

        jLabel1.setFont(new java.awt.Font("Calibri", 0, 16));
        jLabel2.setFont(new java.awt.Font("Calibri", 0, 16));
        omega.setFont(new java.awt.Font("Calibri", 0, 16));
        alpha.setFont(new java.awt.Font("Calibri", 0, 16));

        Comparable zero;
        Number  one;
        if (maxAlpha instanceof Integer){
            zero = (Integer)0;
            one = (Integer)1;
        }
        else{
            zero = (Float)0f;
            one = (Float)1f;
        }

        alpha.setModel(new SpinnerNumberModel(
            defaultAlpha,
            zero,
            maxAlpha,
            one
        ));

        omega.setModel(new SpinnerNumberModel(
            defaultOmega,
            zero,
            maxOmega,
            one
        ));

    }

    public Comparable getAlpha(){
        return (Comparable)alpha.getValue();
    }
    
    public void setAlpha(Comparable value){
        alpha.setValue(value);
    }

    public Comparable getOmega(){
        return (Comparable)omega.getValue();
    }

    public void setOmega(Comparable value){
        omega.setValue(value);
    }

    public JSpinner getAlphaSpinner(){
        return alpha;
    }

    public JSpinner getOmegaSpinner(){
        return omega;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        alpha = new javax.swing.JSpinner();
        jLabel2 = new javax.swing.JLabel();
        omega = new javax.swing.JSpinner();

        setBackground(new java.awt.Color(246, 246, 246));

        jLabel1.setText("Local range parameter:");

        jLabel2.setText("Global range parameter:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addGap(75, 75, 75)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(alpha, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(omega, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(alpha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(omega, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSpinner alpha;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JSpinner omega;
    // End of variables declaration//GEN-END:variables
}
